<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016-07-05
 * Time: 10:34
 */

namespace pdo;


class PdoService
{

    const PARAM_host='127.0.0.1';
    const PARAM_port='3306';
    const PARAM_db_name='3ynet';
    const PARAM_user='root';
    const PARAM_db_pass='123456';

    public $db ;
    public function __construct()
    {
        $this->db = new \PDO("mysql:host=".PdoService::PARAM_host.";dbname=3ynet;charset=utf8","root","123456");
    }


}


$pdo = new PdoService();
$sql = "Select * from 3y_user where id=".'1';


foreach ($pdo->db->query($sql) as $row) {
    print $row['id'] . "\t";
    print $row['username'] . "\t";

}
